package com.xw.Conf;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

import com.xw.Listener.RedisEventListener;

@Configuration
public class RedisEventConfig {
	
	@Autowired
	private JedisConnectionFactory jedisConnectionFactory;
	@Autowired
	private RedisEventListener redisEventListener;
	
	@Bean
	RedisMessageListenerContainer redisContainer() {
	    RedisMessageListenerContainer container  = new RedisMessageListenerContainer(); 
	    container.setConnectionFactory(jedisConnectionFactory); 
	    container.addMessageListener(redisEventListener, new ChannelTopic("BroadCastEvent"));
	    return container; 
	}
}
